package com.drxx.service;

import com.drxx.bean.UserInfo;
import com.drxx.dao.UserInfoDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
@Transactional(readOnly = true)
public class UserInfoService implements IUserInfoService{

    @Autowired
    private UserInfoDao userInfoDao;

    @Override
    public UserInfo findById(int id){
        return  userInfoDao.findById(id);
    }

    @Override
    public int insert(List<UserInfo> userInfoList){
        if(CollectionUtils.isEmpty(userInfoList)){
            throw new NullPointerException("null pointer exception!");
        }
        return userInfoDao.insert(userInfoList);
    }

    @Override
    public UserInfo deleteById(int id) {
        return userInfoDao.findById(id);
    }
}
